package main

import (
	"gitee.com/scottq/go-framework/src/miscs"
	v1job "gitee.com/scottq/go-framework/src/v1/jobserver"
	"time"
)

func main() {

	//创建一个job
	job := v1job.NewJob("printX", func() {
		println(time.Now().Format(miscs.DateTimeLayout))
	})
	job.SetCoNum(2)

	//创建job对应的定时任务调度器
	sch := v1job.NewJobScheduler("scheduler", time.Second, job)

	go func() {
		time.Sleep(time.Second * 10)
		println("stop scheduler", time.Now().Format(miscs.DateTimeLayout))
		sch.Stop()
	}()

	//
	sch.Run()

	println("end")
}
